'use strict';

angular.module('myApp.shop', ['lumx','infinite-scroll']).controller('shopCtrl', ['$scope','$http','$routeParams',
	function($scope,$http,$routeParams){

	var p=1;
	$scope.scroll_switch = false;
	$scope.shop_list = [];
    $scope.myPage = function(){
    	if($scope.scroll_switch) return;
	    $http.get('/consumer/'+userid+'/seller?currentpage='+p).success(function(data){
	    	if (!data.error) {	
	    		if (p>data.result.last_page) {
	    			$scope.scroll_switch = true;
	    		}else{
	    			for (var i = 0; i < data.result.data.length; i++) {
	    				$scope.shop_list.push(data.result.data[i]);
	    			};
		    		$scope.shops =$scope.shop_list;
		    		console.log($scope.shop_list);
		    		p++;
	    		};
	    	};
	    });	  
    };

}]);